<template>
  <div class="network-operating-record">
    <search-table
      :columns="columns"
      :data="operatingRecordList"
      @change-page="changePageNow"
      @change-size="changePageSize"
      :total="total"
      :page.sync="pageIndex"
      :size.sync="pageSize"
    >
      <template slot="select-group">
        <Select filterable
          v-model="teamName"
          placeholder="请选择团队"
          filterable
          clearable
          @on-change="changePageNow(1)"
        >
          <Option
            v-for="item in dataList"
            :value="item.teamName"
            :key="item.id"
            :title="item.teamName"
            >{{ item.teamName }}</Option
          >
        </Select>
      </template>
    </search-table>
  </div>
</template>

<script>
import SearchTable from "@/components/SearchTable/SearchTable";
import {queryLogsList} from '@/api/teamStatistics';
import {getaccessgrouplistdis} from '@/api/access_new';
export default {
  name: "new-network-operating-record",
  components: {
    SearchTable
  },
  props: {
    disabledAllBtn: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      teamName:"",
      operatingRecordList: [],
      total: 0, // 总数据量
      pageSize: 10, // 分页大小
      pageIndex: 1, // 当前页
      columns: [
        {
          placement: "top-left",
          title: "团队名",
          key: "teamName",
          align: "center",
          tooltip: true,
          width: 230,
        },
        {
          placement: "top-left",
          title: "操作",
          key: "externalIpSwitch",
          width: 230,
        },
        {
          title: "操作内容",
          width: 230,
          tooltip: true,
          key: "description",
        },
        {
          title: "操作时间",
          width: 150,
          key: "createTime",
        },
        {
          title: "操作结果",
          key: "result",
          render: (h, params) => {
            let result = params.row.result;
            return h(
              "Tag",
              {
                props: {
                  color:
                    result ? "blue": 'red',
                },
              },
              result?'成功':'失败'
            );
          }
        },
        {
          title: "操作人",
          width: 150,
          key: "userName",
        }
      ],
      dataList:[]
    };
  },
  mounted() {
    this.getqueryLogsList()
    this.getQueryTeamList()
  },
  computed: {},
  methods: {
    getQueryTeamList(){
      getaccessgrouplistdis({
        pageIndex: 1,
        pageSize: 9999,
        isSuperGroup: false
      },this.$route.query.id).then(res=>{
        const filter = res.data.items.filter(item => item.teamName !== '目标方管理员组')
        this.dataList = filter
      })
    },
    //查询
    getqueryLogsList(){
        queryLogsList({
            pageIndex:this.pageIndex,
            pageSize:this.pageSize,
            teamName:this.teamName,
            sceneId:this.$route.query.id
        }).then(data=>{
            if(data.code==1){
                this.operatingRecordList = data.data.items.map(item=>{
                    return {
                        ...item,
                        externalIpSwitch:'外网ip切换'
                    }
                })
                this.total = data.data.total
            }
        }).catch(()=>{
            
        })
    },
    // 修改分页大小
    changePageSize(val) {
      this.pageSize = val;
      this.getqueryLogsList();
    },
    // 修改当前页
    changePageNow(val) {
      this.pageIndex = val;
      this.getqueryLogsList();
    },
  },
  watch: {},
  beforeDestroy() {},
};
</script>

<style scoped>
</style>